﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TiposComuns.Objectos
{
    /// <summary>
    /// Represents the addresses of the three servers, where a user is hosted.
    /// </summary>
    [Serializable]
    public class Address
    {
        /// <summary>
        /// Client's URI
        /// </summary>
        public string URI
        {
            get;
            set;
        }

        /// <summary>
        /// Client's port
        /// </summary>
        public int Port
        {
            get;
            set;
        }

        public Address(string uri, int port)
        {
            this.URI = uri;
            this.Port = port;
        }

        public Address(){}

        public override string ToString()
        {
            return String.Format("{0}:{1}",this.URI,this.Port);
        }

        /// <summary>
        /// Obtains the complete uri for a specified server
        /// </summary>
        /// <param name="server">Server number</param>
        /// <returns>Complete uri</returns>
        public string GetURI(int server)
        {
            return String.Format("{0}:{1}",this.URI,this.Port+(server+1));
        }

        public Address Clone()
        {
            return new Address(this.URI, this.Port);
        }
    }
}
